/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     ListNode *next;
 *     ListNode() : val(0), next(nullptr) {}
 *     ListNode(int x) : val(x), next(nullptr) {}
 *     ListNode(int x, ListNode *next) : val(x), next(next) {}
 * };
 */
struct ListNode
{
    int val;
    ListNode *next;
    ListNode() : val(0), next(nullptr) {}
    ListNode(int x) : val(x), next(nullptr) {}
    ListNode(int x, ListNode *next) : val(x), next(next) {}
};


class Solution
{
public:
    ListNode *mergeTwoLists(ListNode *l1, ListNode *l2)
    {
        // 均有值
        ListNode head = ListNode(-1), *current = nullptr;
        
        current = &head;
        while (l1 != nullptr && l2 != nullptr) {
            if (l1->val >= l2->val) {
                current->next = l2;
                l2 = l2->next;
            }
            else {
                current->next = l1;
                l1 = l1->next;
            }
            current = current->next;
        }
        
        // 查看哪个还没到底
        current->next = (l1 == nullptr) ? l2 : l1;
        return head.next;
    }
};